import * as actionType from './constants.js';
import {reqClassifyList,reqClassify} from '@/api'

export const setClassifyList=(data)=>{
    return {
        type:actionType.SET_CLASSIFY_LIST,
        data:data
    }
}

export const getClassifyList=()=>{
    return (dispatch)=>{
        reqClassifyList()
            .then(res=>{
                dispatch(setClassifyList(res.data.data))
            })
    }
}

export const setClassifyRecommand=(data)=>{
    return {
        type:actionType.SET_CLASSIFY_REOCOMMAND,
        data
    }
}

export const setClassifySecondMenu=(data)=>{
    return {
        type:actionType.SET_CLASSIFY_SECOND_MENU,
        data
    }
}

export const getClassifyData=()=>{
    return (dispatch)=>{
        reqClassify()
            .then((res)=>{
                dispatch(setClassifyRecommand(res.data.data.recommend))
                dispatch(setClassifySecondMenu(res.data.data.classifySecondMenu.classifySecondMenu))
            })
    }
}